package me.notelife.svnmonitor.service;

import java.util.List;

import me.notelife.svnmonitor.dao.ConnectionFactory;
import me.notelife.svnmonitor.dao.VCSLogDAO;
import me.notelife.svnmonitor.domain.VCSLogEntry;

import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;

public class VCSLogService
{
    Logger logger = Logger.getLogger( VCSLogService.class );

    public List<VCSLogEntry> getAllVCSLogEntries() throws Exception
    {
        SqlSession session = ConnectionFactory.getSession().openSession();
        VCSLogDAO dao = session.getMapper( VCSLogDAO.class );
        List<VCSLogEntry> entries = dao.getAllVCSLogEntries();
        session.close();
        return entries;
    }
    
    public VCSLogEntry createVCSLogEntry( VCSLogEntry entry ) throws Exception
    {
        SqlSession session = ConnectionFactory.getSession().openSession();
        VCSLogDAO dao = session.getMapper( VCSLogDAO.class );
        dao.createVCSLogEntry( entry );
        session.commit();
        session.close();
        return entry;
    }

}
